<!--智慧政务-办理指南列表-->
<template>
	<view class="body">
		<view class="banner">
			<image src="@/static/banner.png" style="width: 100%;" mode="widthFix"></image>
		</view>

		<!-- 搜索框 开始 -->
		<view class="select-box">
			<view class="inp">
				<uni-icons type="search" color="#3E9CF9"></uni-icons>
				<input type="text" v-model="kw" placeholder="请输入搜索内容" placeholder-style="font-size: 24rpx;" style="font-size: 24rpx;margin-left: 12rpx;width: 100%;" />
			</view>
			<view>
				<view class="button-class" @click="search">搜索</view>
			</view>
		</view>
		<!-- 搜索框 结束 -->
		<view class="list">
			<view class="listcontent" v-for="(item,index) in affairs" v-on:click="gotoAffairsDetail(item)">
				<view class="list-icon">
					<image class='icon' src='@/static/bszl.png'></image>
				</view>

				<view class="listtext">
					<view class="title-1">
						<view class="title-2">
							{{item.title}}
						</view>
						<view class="title-3">
							<image class="title-3-image" src='@/static/jz.png'></image>
						</view>
					</view>
					<!-- <view class="timelist">
						{{item.publishTime}}
					</view> -->
				</view>
			</view>
			<uni-load-more :status="loadingType"></uni-load-more>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import empty from '@/components/empty.vue'
	export default {
		data() {
			return {
				communityId: this.$api.util.getAreaCode(),
				affairs: [],
				time: '',
				page: 1,
				total: 0,
				key: '',
				loadingType: 'more',
				// 搜索框
				kw: '',
			}
		},
		computed: {
			...mapState(['defaultCommunityId']),
		},
		onLoad() {
			this.getData()
			// this.$api.sysauth.checkLoginAndBindCommunity();
		},
		onReachBottom() {
			if (this.loadingType === 'more') {
				this.page = this.page + 1;
				this.getData()
			}
		},
		components: {
			empty
		},
		methods: {
			search() {
				this.page = 1;
				this.affairs = [];
				this.getData()
			},
			//办事指南模糊查询
			getData() {
				let params = {
					"areaCode": this.communityId,
					"articleType": "GUIDE",
					"title": this.kw,
					"startIndex": this.page,
					"pageSize": 10,
					"published": true
				}
				this.$api.request.inquiryArticlePagination(params, (res) => {
					console.log(res.body.data.list)
					if (res.body.status.statusCode == "0") {
						let newLists = res.body.data.articles
						this.affairs = this.affairs.concat(newLists);
						let total = res.body.data.totalCount
						if (this.affairs.length >= total) {
							this.loadingType = 'noMore'
						} else {
							this.loadingType = 'more'
						}
					}
				})
			},
			searchData() {
				this.page = 1;
				this.affairs = [];
				this.getData();
			},
			gotoAffairsDetail(item) {
				uni.navigateTo({
					url: '/pages/smartaffairs/affairdetail?id=' + item.articleUuid
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F8F8F8;
	}

	.banner {
		text-align: center;

		image {
			border-radius: 8rpx;
			width: 686rpx;
			height: 240rpx;
		}
	}

	.select-box {
		margin-top: 30upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.inp {
		width: calc(100% - 160rpx);
		display: flex;
		align-items: center;
		border: 1px solid #999999;
		border-radius: 10rpx;
		line-height: 50upx;
		font-size: 24rpx;
		padding: 6rpx 10rpx 6rpx 30rpx;

		/* margin-left: 40rpx; */
		input {
			margin-left: 10rpx;
		}
	}

	.body {
		width: 100%;
		height: 100%;
		padding-left: 20upx;
		padding-right: 20upx;
		background: #F7F8FC;
	}

	.search {
		width: 100%;
		height: 80upx;
		padding-top: 10upx;
		background-color: rgba(255, 255, 255, 1);
		/* z-index: 99; */
		transition: all .5s;
		display: flex;
		position: relative;
	}

	.search-c {
		height: 100%;
		position: relative;
		width: 75%;
		margin-right: 1%;
		z-index: 99;
	}

	.search-input {
		background-color: #E9E9E9;
		/* background-color: red; */
		width: 100%;
		height: 100%;
		box-sizing: border-box;
		line-height: 50upx;
		border-radius: 50upx;
		font-size: 24upx;
		transition: all .5s;
		padding: 10upx 30upx 10upx 90upx;
	}

	.search-input-p {
		color: #999;
		width: 100%;
		height: 100%;
		padding: 0 !important;
	}

	.search-input-p-c {
		position: relative;
		top: 50%;
		transform: translateY(-50%);
	}

	.search-icon {
		position: absolute;
		top: 50%;
		left: 30upx;
		right: 30upx;
		transform: translateY(-50%);
		z-index: 999;
	}

	.icon {
		width: 40upx;
		height: 40upx;
		z-index: 999;
		/* #ifdef MP-ALIPAY */
		background-size: 100% 100%;
		/* #endif */
	}

	.search .btn {
		width: 20%;
		background-color: #f1f1f1;
		font-size: 28upx;
		color: #333;
		height: 72upx;
		line-height: 72upx;
	}

	.list {
		width: 100%;
		height: 100%;
		padding-top: 20upx;
		background: #F7F8FC;

	}

	.listcontent {
		width: 100%;
		height: 110upx;
		margin-top: 20upx;
		border-radius: 15upx;
		background-color: white;
		position: relative;
		display: flex;
		justify-content: left;
		align-items: center;

	}

	.list-icon {
		/* position: absolute;
		top: 50%;
		left: 30upx;
		right: 30upx;
		transform: translateY(-50%); */
		text-align: center;
		font-weight: lighter;
		margin-right: 8upx;
		z-index: 99;
		padding: 12upx;
		width: 100upx;
		/* height: 110upx; */
		/* border-radius: 25upx; */
		border-radius: 15upx 0 0 15upx;
	}

	.new_text {
		/* display: inline-block; */
		color: #E7526C;
		margin-right: 4upx;
		text-align: center;
		font-size: 20upx;
		line-height: 90upx;
		border: 2px solid #E7526C;
		padding: 2upx;
		transition: all .5s;
		border-radius: 6upx;
	}

	.listtext {
		width: 100%;
		/* height: 100%; */
		box-sizing: border-box;
		/* border-radius: 50upx; */
		font-size: 30upx;
		font-weight: bold;
		transition: all .5s;
		padding: 10upx 30upx 10upx 6upx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.timelist {
		font-family: 'PingFang SC';
		font-style: normal;
		font-weight: 500;
		font-size: 12px;
		margin-top: 5px;
		line-height: 17px;
		/* identical to box height */
		color: #999CA3;
	}

	.title-1 {
		display: flex;
	}

	.title-2 {
		display: flex;
		flex-direction: column;
		width: 85%;
	}

	.title-3 {
		margin-left: 10%;
		display: flex;
		flex-direction: column;
		width: 5%;
		text-align: center;
		color: #999CA3;
	}

	.title-3-image {
		width: 12px;
		height: 12px;
		margin-top: 5px;
	}

	.button-class {
		width: 140rpx;
		height: 64rpx;
		line-height: 64rpx;
		font-size: 26rpx;
		border-radius: 10rpx;
		text-align: center;
		background-color: #3E9CF9;
		color: white;
	}
</style>
